package com.cs307.redcross.client;

import java.io.Serializable;
import java.util.Date;
import java.util.Vector;

public class ReminderTemplate extends Reminder implements Serializable {
	private static final long serialVersionUID = 5035145869875499527L;
	private int minutesInWeek = 10080;
	private int minutesInDay = 1440;
	private String name;
	private int timeBeforeEvent; //represents time before the event in the form of minutes
	
	
	public ReminderTemplate() {

	}

	public ReminderTemplate(String name, int time, Vector<Group> gr, Vector<Person> pe, String mes) {
		super(null, null, gr, pe, mes);
		this.name = name;
		this.timeBeforeEvent = time;
	}
	
	public ReminderTemplate(ReminderTemplate rt) {
		if (rt.name != null)
			this.name = rt.name;
		else
			this.name = "";
		
		if (rt.message != null)
			this.message = rt.message;
		else
			this.message = "";
			
		this.timeBeforeEvent = rt.timeBeforeEvent;
		this.email = rt.email;
		this.SMS = rt.SMS;
	}

	public String getName() {
		return name;
	}
	
	public Date getTimeOfReminderFromTemplate(Date date) {
		return new Date(date.getTime()-this.getTimeBeforeEvent()*60*1000);
	}
	
	public int getId() {
		return super.getID();
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getTimeBeforeEvent() {
		return timeBeforeEvent;
	}
	
	public int getWeeksBeforeEvent() {
		return timeBeforeEvent / minutesInWeek;
	}
	
	public int getDaysBeforeEvent() {
		return (timeBeforeEvent % minutesInWeek) / minutesInDay;
	}
	
	public int getHoursBeforeEvent() {
		return ((timeBeforeEvent % minutesInWeek) % minutesInDay) / 60;
	}
	
	public int getMinutesBeforeEvent() {
		return (((timeBeforeEvent % minutesInWeek) % minutesInDay) % 60);
	}

	public void setTimeBeforeEvent(int timeBeforeEvent) {
		this.timeBeforeEvent = timeBeforeEvent;
	}
}
